﻿using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Thinker.SignChannel.Entities;
using Thinker.SignChannel.Repositories;

namespace Thinker.SignChannel;

public static class AppMock
{
    public static Person MockPerson(string idNumber = "100000000000000001",
        string personName = "张1",
        string? personType = "组长1",
        string? personCode = "Z001",
        string? sex = "男1",
        Guid? id = null)
    {
        return new Person(
            idNumber: idNumber,
            personName: personName,
            sex: sex,
            personType: personType,
            personCode: personCode,
            id: id ?? Guid.NewGuid()
        );
    }

    public static async Task<Person> MockPersonAsync(this IServiceProvider serviceProvider,
        string idNumber = "100000000000000001",
        string personName = "张1",
        string? personType = "组长1",
        string? personCode = "Z001",
        string? sex = "男1",
        Guid? id = null)
    {
        var person = MockPerson(idNumber, personName, personType, personCode, sex, id);
        return await serviceProvider.GetRequiredService<IPersonRepository>()
            .InsertAsync(person, true);
    }
}